package memory

import (
	"github.com/shirou/gopsutil/v3/mem"
	monproto "gollect/proto"
	"time"
)

func Collect(interval time.Duration) *monproto.MemoryInfo {
	vm, err := mem.VirtualMemory()
	if err != nil {
		return &monproto.MemoryInfo{}
	}
	return &monproto.MemoryInfo{
		Total:       vm.Total,
		Used:        vm.Used,
		Free:        vm.Free,
		UsedPercent: float32(vm.UsedPercent / 100.0),
	}
} 